﻿using AutoMapper;
using MediatR;
using S.Eartag.API.Application.Command.LamBingCommand;
using S.Eartag.Domain.Model;
using S.Eartag.Infrastructure.Impl;
using S.Eartag.Infrastructure.Interface;

namespace S.Eartag.API.Application.CommandHandlers.LamBingCommandHandler
{
    public class LamBingDeleteCommandHandler : IRequestHandler<LamBingDeleteCommand, int>
    {
        private readonly ILamBingRepository lamBingRepository;
        private readonly IMapper mapper;
        public LamBingDeleteCommandHandler(ILamBingRepository lamBingRepository, IMapper mapper)
        {
            this.lamBingRepository = lamBingRepository;
            this.mapper = mapper;
        }

        public async Task<int> Handle(LamBingDeleteCommand request, CancellationToken cancellationToken)
        {
            var res = await lamBingRepository.Get(request.Id);
            res.IsDel = true;
            var info = lamBingRepository.Update(res);
            return await info;
        }
    }
}
